#ifndef __SP_SESSION_H_INCLUDED__
#define __SP_SESSION_H_INCLUDED__ 

#include "PacketHeader.h"
#include "fd.h"
#include "RecvBuffer.h"
#include "SendBuffer.h"

class  NetworkObject;

class Session
{
public:
	Session(size_t nSendBufferSize, size_t nRecvBufferSize, size_t nMaxPacketSize);
	~Session(void);
public:
	//
	void OnAccept();
public:

	void Disconnect(bool bGrace) { m_bRemove = true;}

	bool ShouleBeRemove() { return m_bRemove;}

	bool Send(unsigned char* pMsg, size_t nSize);

	bool ProcessRecvdPacket(size_t nMaxPacketSize);
public:
	//
	void BindNetworkObject(NetworkObject* pNetwork);
	//
	void UnBindNetworkObject();
	//
	NetworkObject* GetNetworkObject() { return m_pNetworkObject;}
	//
	void SetSocket(fd_t socket) { m_socket = socket;}
	//
	fd_t GetSocket() { return m_socket;}
	//
	SendBuffer* GetSendBuffer() { return m_pSendBuffer;}
	//
	RecvBuffer* GetRecvBuffer() { return m_pRecvBuffer;}


private:
	SendBuffer* m_pSendBuffer;
	RecvBuffer* m_pRecvBuffer;
	NetworkObject* m_pNetworkObject;
	fd_t m_socket;

	volatile bool m_bRemove;
};

#endif
